              ; Various tests for output filter and DAC.  I used a Nippon Precision Circuits
              ; SM5813AP dual-channel 8-times oversampling digital filter into a Burr Brown
              ; PCM1700P dual-channel 18-bit DAC.  The code is very specific to my hardware.
              ;
              ; available signals:
              ;       impulse
              ;       square
              ;       triangle
              ;       sine            (uses twin-integrator harmonic oscillator)
              ;
              ; This code is not interrupt driven but simple spins waiting for transmitter
              ; ready on each sample.
              ;
              ;
              ; written by Quinn Jensen
              ; home: jensenq@qcj.icon.com
              ;
              include "ioequ.inc"
              
P:0000                org     p:$0000
P:0000 0C0040         jmp     <start
              
P:000C                org     p:$000C
              ;ssi    jsr     ssi_int                         ;go handle SSI interrupt
              
              ; data areas
              
X:0000                org     x:$0
X:0000 000000 i_left  dc      0                               ;left channel in
X:0001 000000 i_right dc      0                               ;right channel in
              
P:0040                org     p:$40
P:0040        start
              
              ; assign mode
              
P:0040 05F439         movec   #$0300,sr                       ;go to IPL 3
P:0041 000300
              
              ; set up interrupts
              
              ;       movep   #0<<13|3<<12|0<<10,x:m_ipr      ;put SSI at lev 3, others off
              
              ; set system sample rate
              
P:0042 0AA406         bclr    #6,x:<<m_pbd                    ;32.55 kHz
P:0043 0AA425         bset    #5,x:<<m_pbd                    ;
P:0044 0AA404         bclr    #4,x:<<m_pbd                    ;
              
              ; set up SSI
              
P:0045 08F4AC         movep   #2<<13|1<<8,x:m_cra             ;16-bit word, 2 time slots
P:0046 004100
P:0047 08F4AD         movep   #0<<15|3<<12|1<<11|1<<9,x:m_crb ;sync,network,enable
P:0048 003A00
              
P:0049 08F4A3         movep   #0,x:m_pcddr                    ;port C is SSI/SCI
P:004A 000000
P:004B 08F4A1         movep   #$1FF,x:m_pcc                   ;port C is SSI/SCI
P:004C 0001FF
              
              ; enable interrupts
              
              ;       movec   #0,sr                           ;lower IPL
              
P:004D 0C004E         jmp     <impulse                        ;jump to the desired signal
              
              ; impulse
              
P:004E        impulse
P:004E 56F400         move    #>-.5,a
P:004F C00000
              
P:0050        im1
P:0050 069081         do      #400,im0
P:0051 000052
P:0052 0D0057         jsr     <imp
P:0053        im0     
P:0053 200036         neg     a
P:0054 0D0057         jsr     <imp
P:0055 200036         neg     a
P:0056 0C0050         jmp     <im1
              
P:0057        imp
P:0057 0AAE86         jclr    #6,x:m_sr,*                     ;wait for transmitter ready
P:0058 000057
P:0059 08CE2F         movep   a,x:m_tx
P:005A 0AAE86         jclr    #6,x:m_sr,*                     ;wait for transmitter ready
P:005B 00005A
P:005C 08CE2F         movep   a,x:m_tx
P:005D 00000C         rts
              
              ; square wave
              
P:005E        square
P:005E 56F400         move    #>-.1,a
P:005F F33333
              
P:0060        sq1
P:0060 06C880         do      #200,sq0
P:0061 000067
P:0062 0AAE86         jclr    #6,x:m_sr,*                     ;wait for transmitter ready
P:0063 000062
P:0064 08CE2F         movep   a,x:m_tx
P:0065 0AAE86         jclr    #6,x:m_sr,*                     ;wait for transmitter ready
P:0066 000065
P:0067 08CE2F         movep   a,x:m_tx
P:0068        sq0     
P:0068 200036         neg     a
P:0069 0C0060         jmp     <sq1
              
              
              ; triangle wave
              
P:006A        triangle
P:006A 44F400         move    #>.010,x0
P:006B 0147AE
P:006C 56F400         move    #>-.9,a
P:006D 8CCCCD
              
P:006E        l0      
P:006E 06B480         do      #90*2,l1
P:006F 000076
P:0070 200040         add     x0,a
P:0071 0AAE86         jclr    #6,x:m_sr,*                     ;wait for transmitter ready
P:0072 000071
P:0073 08CE2F         movep   a,x:m_tx
P:0074 0AAE86         jclr    #6,x:m_sr,*                     ;wait for transmitter ready
P:0075 000074
P:0076 08CE2F         movep   a,x:m_tx
P:0077        l1
P:0077 208F00         move    x0,b
P:0078 20003E         neg     b
P:0079 21E400         move    b,x0
P:007A 0C006E         jmp     <l0
              
              
              ; sine wave
              
P:007B        sine
P:007B 44F400         move    #>.050,x0                       ;oscillator freq
P:007C 066666
P:007D 56F400         move    #>-.209,a                       ;initial conditions
P:007E E53F7D
P:007F 57F400         move    #>.2090,b                       ;
P:0080 1AC083
              
P:0081        loop
P:0081 2000D2         mac     x0,y0,a
P:0082 21C600         move    a,y0
P:0083 0AAE86         jclr    #6,x:m_sr,*                     ;wait for transmitter ready
P:0084 000083
P:0085 08CE2F         movep   a,x:m_tx                
P:0086 2000DE         mac     -x0,y0,b
P:0087 21E600         move    b,y0
P:0088 0AAE86         jclr    #6,x:m_sr,*                     ;wait for transmitter ready
P:0089 000088
P:008A 08CF2F         movep   b,x:m_tx                
              
P:008B 0C0081         jmp     <loop
              
                      end

Summary of psect usage

                 section seg base last top      used       avail    total
-------------------------------------------------------------------------


Symbol Table
-------------------------------------
             sq0 000068
             sq1 000060
          square 00005E
            loop 000081
             imp 000057
             im0 000053
             im1 000050
         impulse 00004E
        triangle 00006A
           start 000040
            sine 00007B
          m_scl1 00000F
          m_scl0 00000E
           m_scl 00C000
          m_ssl1 00000D
          m_ssl0 00000C
           m_ssl 003000
          m_hpl1 00000B
          m_hpl0 00000A
           m_hpl 000C00
          m_ibl2 000005
          m_ibl1 000004
          m_ibl0 000003
           m_ibl 000038
          m_ial2 000002
          m_ial1 000001
          m_ial0 000000
           m_ial 000007
           m_ipr 00FFFF
           m_rdf 000007
           m_tde 000006
           m_roe 000005
           m_tue 000004
           m_rfs 000003
           m_tfs 000002
           m_if1 000001
           m_if0 000000
            m_if 000002
          m_srie 00000F
          m_stie 00000E
           m_sre 00000D
           m_ste 00000C
           m_mod 00000B
           m_gck 00000A
           m_syn 000009
           m_fsl 000008
          m_sckd 000005
          m_scd2 000004
          m_scd1 000003
          m_scd0 000002
           m_scd 00001C
           m_of1 000001
           m_of0 000000
            m_of 000003
           m_psr 00000F
           m_wl1 00000E
           m_wl0 00000D
            m_wl 006000
            m_dc 001F00
            m_pm 0000FF
           m_tsr 00FFEE
            m_sr 00FFEE
           m_crb 00FFED
           m_cra 00FFEC
            m_tx 00FFEF
            m_rx 00FFEF
           m_tcm 00000F
           m_rcm 00000E
           m_scp 00000D
           m_cod 00000C
            m_cd 000FFF
            m_r8 000007
            m_fe 000006
            m_pe 000005
            m_or 000004
          m_idle 000003
          m_rdrf 000002
          m_tdre 000001
          m_trne 000000
          m_tmie 00000D
           m_tie 00000C
           m_rie 00000B
          m_ilie 00000A
            m_te 000009
            m_re 000008
          m_woms 000007
           m_rwi 000006
          m_wake 000005
           m_sbk 000004
          m_wds2 000002
          m_wds1 000001
          m_wds0 000000
           m_wds 000003
          m_sccr 00FFF2
           m_ssr 00FFF1
           m_scr 00FFF0
          m_stxa 00FFF3
          m_stxh 00FFF6
          m_stxm 00FFF5
          m_stxl 00FFF4
          m_srxh 00FFF6
          m_srxm 00FFF5
          m_srxl 00FFF4
           m_dma 000007
           m_hf1 000004
           m_hf0 000003
            m_hf 000018
           m_hcp 000002
          m_htde 000001
          m_hrdf 000000
           m_hf3 000004
           m_hf2 000003
          m_hcie 000002
          m_htie 000001
          m_hrie 000000
           m_htx 00FFEB
           m_hrx 00FFEB
           m_hsr 00FFE9
           m_hcr 00FFE8
           m_pcd 00FFE5
         m_pcddr 00FFE3
           m_pcc 00FFE1
           m_pbd 00FFE4
         m_pbddr 00FFE2
           m_pbc 00FFE0
           m_bcr 00FFFE
         i_right 000001
          i_left 000000
              l0 00006E
              l1 000077
errors=0
